<template>
		<div>
			<div>
				<ul class="aui-list aui-media-list address_list"  style="text-align: left;">
					<li class="aui-list-item address-root" >  <!--v-if="!login"-->
						
						<span>登录后获取常用地址</span><span>登录</span><span style="clear: both;"></span>
						
					</li>
					<!--<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-title">优惠金额</div>
							<div id="co_totalMinis" class="aui-list-item-right"><span>登录</span></div>
						</div>
					</li>-->
					<li class="aui-list-item address-root" v-for="(item,index) in filterAddress"  @click="getNow(item,index)" v-if="login">
						<div class="aui-media-list-item-inner">
							<div class="aui-list-item-label-icon">
								<i class="icon njfont nj-dizhi"></i>
							</div>
							<div class="aui-list-item-inner clear_b">
								<div class="aui-list-item-text">													<!--?item.receivername:userInfomation.mobile-->
									<div class="aui-list-item-title">
										<strong id="#uvipname" class="uvipname">收货人:{{item.receivername}}</strong>
										<span class="aui-font-size-14 text_c_gray"></span>
									</div>
								</div>
								<p class="address_float"><span class="aui-label aui-label-info">标签</span>&nbsp;<span class="show-address">{{item.result}}</span></p>
							</div>
							<div class="aui-list-item-label-icon" >
								<i class="icon njfont nj-xuanzhong" style="color: #74AE56;" v-if="activeIndex == index"></i>
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
</template>

<script>
	import { mapMutations, mapGetters } from 'vuex';
	import axios from 'axios';
	import MyHeader from "../header";
	import {Toast} from '../../utils/toast';
	//	import { Popup } from 'mint-ui';
	export default {
		props: {
			
		},
		components: {
			"my-header": MyHeader,
		},
		computed: {
			...mapGetters('zx', [
				
			]),
			...mapGetters('wxh', [
		        "login",
		        'userInfo',
		        'sessionId'
		    ]),
			zxPageHeight(){
				return window.screen.height;
			},
			zxPageWidth(){
				return window.environment === "edit" ? 375 : window.screen.width;
			},
			filterAddress(){
				
				if(this.address){
					var address = null;
			        for(let i = 0 ; i < this.address.length; i++){
			       		if(this.address[0].defaultaddress != 1 && this.address[i].defaultaddress == 1){
			       			address = this.address[0];
			       			this.address[0] = this.address[i];
			       			this.address[i] = address;
			       		}
			        }
			        return this.address;
				}
			},
			getChooseAddressNow(){
				return this.chooseAddressNow;
			}
		},
		watch: {
			userInfo(newVal,oldVal){
				this.checkLogin();
			}
		},
		data() {
			return {
				activeIndex:null,
				address:null, //地址列表
				chooseAddressNow:null,
			}
		},
		mounted(){
			
		},
		created() {
			this.checkLogin();
		},
		beforeDestroy() {
		
	    },
		methods: {
			...mapMutations('zx',[
				"setHomeAddressNow","setHomeStoreNow","setIsShow","setUseMapFlag"
			]),
			getNow(item,index){
				if(this.activeIndex != index){
					this.activeIndex = index;
					this.chooseAddressNow = item;
				}else{
					this.activeIndex = null;
					this.chooseAddressNow = null;
				}
				console.log(this.getChooseAddressNow)
			},
			checkLogin(){
				if(this.login){
					console.log('已登陸');
					this.getAddress();
				}else{
					console.log('未登錄');
				}
			},
			//获取地址信息
			getAddress(){
				if(this.userInfo){
					this.address = this.userInfo.addressLists;
				}
			},
			cancelChoose(){
				this.activeIndex = null;
				this.chooseAddressNow = null;
			}
		}
	}
</script>

<style scoped="scoped">
	
</style>